package com.dingup.homework.feign.server.mock;

import com.dingup.homework.service.HwHomeworkRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import static com.dingup.homework.util.ConstUtil.*;

/**
 * @author jun 2018/11/19.
 */
@RestController()
@RequestMapping("/feign/homework_record")
public class HomeworkRecordFeign {

    @Autowired
    private HwHomeworkRecordsService hwHomeworkRecordsService;

    @RequestMapping(value = "/save_homework_progress.do", method = RequestMethod.POST)
    public void saveHomeworkProgress(@RequestParam(PARAM_HOMEWORK_RECORD_ID) Integer homeworkRecordId,
                                     @RequestParam(PARAM_HOMEWORK_QUESTION_NUM) Integer homeworkQuestionNum,
                                     @RequestParam(PARAM_ID) Integer id,
                                     @RequestParam(PARAM_EXAM_ID) String examId,
                                     @RequestParam(PARAM_CORRECT) Integer correct,
                                     @RequestParam(PARAM_TOTAL) Integer total) {
        hwHomeworkRecordsService.saveHomeworkProgress(homeworkRecordId, homeworkQuestionNum, id, examId, correct, total);
    }

    @RequestMapping(value = "/get_homework_id.do", method = RequestMethod.POST)
    public Integer getHomeworkIdByHomeworkRecordId(@RequestParam(PARAM_HOMEWORK_RECORD_ID) Integer homeworkRecordId) {
        return hwHomeworkRecordsService.getHomeworkIdByHomeworkRecordId(homeworkRecordId);
    }
}
